package com.talos.ums.dal.mysql.roleuser;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.roleuser.vo.UmsRoleUserPageReqVO;
import com.talos.ums.dal.dataobject.roleuser.UmsRoleUserDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 角色用户关系表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsRoleUserMapper extends BaseMapperX<UmsRoleUserDO> {

    default PageResult<UmsRoleUserDO> selectPage(UmsRoleUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsRoleUserDO>()
                .eqIfPresent(UmsRoleUserDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UmsRoleUserDO::getRoleId, reqVO.getRoleId())
                .eqIfPresent(UmsRoleUserDO::getUserCode, reqVO.getUserCode())
                .eqIfPresent(UmsRoleUserDO::getRoleCode, reqVO.getRoleCode())
                .eqIfPresent(UmsRoleUserDO::getWarehouseCode, reqVO.getWarehouseCode())
                .betweenIfPresent(UmsRoleUserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsRoleUserDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsRoleUserDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(UmsRoleUserDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsRoleUserDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsRoleUserDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsRoleUserDO::getTenantId, reqVO.getTenantId())
                .eqIfPresent(UmsRoleUserDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsRoleUserDO::getModifierId, reqVO.getModifierId())
                .orderByDesc(UmsRoleUserDO::getId));
    }

}
